<?php
/**
 * GameModel
 * 
 * @author Admin
 * @version 
 */
require_once 'Zend/Db/Table/Abstract.php';
class Wap_Models_PageModel extends Zend_Db_Table_Abstract
{
    /**
     * The default table name 
     */
    protected $_name = 'tbl_page';
    protected $_primary = 'id';

    function getListPage($page=1){
        $db = Zend_Db_Table::getDefaultAdapter();
        $mySql = $db->select()
                    ->from($this->_name)
                    ->where('active = 1')
                    ->order('id desc')
                    ->limitPage($page, 10);
    //echo $mySql;die;
        $result = $db->fetchAll($mySql);
        return $result;
    }

    function getListPageNotIdView($id){
        $db = Zend_Db_Table::getDefaultAdapter();
        $mySql = $db->select()
                    ->from($this->_name)
                    ->where('active = 1 and id !=?', $id)
                    ->order('id desc')
                    ->limit(10);
    //echo $mySql;die;
        $result = $db->fetchAll($mySql);
        return $result;
    }

    function getCountAllPage(){
        $db = Zend_Db_Table::getDefaultAdapter();
        $mySql = $db->select()
                    ->from(array('p'    => $this->_name),array('count_note' => 'count(*)'))
                    ->where('active = 1');

        $result = $db->fetchRow($mySql);
        return $result['count_note'];
    }

    function getPageID($id){
        $db = Zend_Db_Table::getDefaultAdapter();
        $mySql = $db->select()
                    ->from($this->_name)
                    ->where('id=?', $id) ;   
    //echo $mySql;die;
        $result = $db->fetchRow($mySql);

        return $result;
    }


}